export default {
  namespaced: true, // 开启命名空间
  state: {
    token: localStorage.getItem('geek-store-token'),
    refreshToken: localStorage.getItem('geek-store-token')
  },
  mutations: {
    setToken (state, newToken) {
      state.token = newToken // 将仓库中的token更新了
      localStorage.setItem('geek-store-token', newToken) // 将token更新到本地存储
    },
    setRefreshToken (state, refreshToken) {
      // 1. 修改vuex的数据
      state.refreshToken = refreshToken
      // 2. 同步修改本地
      localStorage.setItem('geek-store-token', refreshToken)
    }
  }
}
